<?php
/**
 * Created by PhpStorm
 * user: MingLiang
 * Date：2021/8/23
 * Time: 11:35 上午
 */


namespace app\admin\model;


use app\common\model\TimeModel;
use think\Exception;

class CostPurchaselist extends TimeModel
{
    protected $deleteTime = 'delete_time';

    public function company()
    {
        return $this->belongsTo('app\admin\model\CostCompany', 'company_id', 'id');
    }
    public function classify()
    {
        return $this->belongsTo('app\admin\model\CostClassify', 'classify_id', 'id');
    }

    public function classifys()
    {
        return $this->belongsTo('app\admin\model\CostClassify', 'last_class_id', 'id');
    }

    public static function create_data($data){
        self::startTrans();
        try {
            foreach($data as $value){
                self::create($value);
            }

            self::commit();
        }catch (Exception $e){
            self::rollback();
            return false;
        }
        return true;
    }
}